Options +ExecCGI
# AddHandler cgi-script .cgi

# Other useful info for deploying on TuxFamily
# https://faq.tuxfamily.org/WebArea/En#How_to_play_with_types_and_handlers

Options +FollowSymLinks
Options -MultiViews
RewriteEngine On
RewriteBase /

# Redirect everything to HTTPS
RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Remove www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]

# Remove trailing slashes
# Do we need this rule? It's probably better not to use it, as it
# could interfere with any regex match in some topic.
# RewriteCond %{REQUEST_FILENAME} !-d
#    RewriteRule ^(.*)/+$ /$1 [NC,L,R=301,QSA]

# Redirect all requests to CGI script
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ freepost.cgi/$1 [L]
